package StudyCode.summary.mycollection;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class FileToList {
	public static List<String> fileToList(File file, boolean toLowerCase,
	                                      boolean trim) {
		try {
			List<String> list = new ArrayList<String>();
			BufferedReader br = new BufferedReader(new FileReader(file));
			String line = "";
			while ((line = br.readLine()) != null) {
				if (toLowerCase)
					list.add(line.toLowerCase());
				else if (trim)
					list.add(line.trim());
				else
					list.add(line);
			}
			return list;
		} catch (Exception e) {
			return null;
		}
	}
}
